<?php

/**
 * This is the model class for table "drink".
 *
 * The followings are the available columns in table 'drink':
 * @property integer $drinkid
 * @property integer $drinktypeid
 * @property string $drinkname
 * @property double $drinkprice
 * @property string $imgpath
 */
class Drink extends DrinkBase
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Drink the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
                    'drinktype' => array(self::BELONGS_TO, 'Drinktype', 'drinktypeid')
		);
	}
        
        /**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'drinkid' => 'Drink ID',
			'drinktypeid' => 'Drink Type ID',
			'drinkname' => 'Drink Name',
			'drinkprice' => 'Drink Price',
			'imgpath' => 'Imgae Path',
		);
	}
	
	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('drinkid',$this->drinkid);
		$criteria->compare('drinktypeid',$this->drinktypeid);
		$criteria->compare('drinkname',$this->drinkname,true);
		$criteria->compare('drinkprice',$this->drinkprice);
		$criteria->compare('imgpath',$this->imgpath,true);
                
		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}